package com.guigu.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.guigu.pojo.PurchaseDetailInfo;
import com.guigu.service.PurchaseDetailInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@CrossOrigin
@RestController
@RequestMapping("purchaseDetail/")
public class PurchaseDetailInfoController {

    //采购详情
    @Autowired
    PurchaseDetailInfoService purchaseDetailService;

    //根据采购单id查询采购详情
    @GetMapping("purchaseDetail.action")
    public Page<PurchaseDetailInfo> queryPurchaseDetails(PurchaseDetailInfo detail,
            @RequestParam(value = "pageno",defaultValue = "1")Integer pageno,
            @RequestParam(value = "pagesize",defaultValue = "5")Integer pagesize){
        return purchaseDetailService.queryPurchaseDetails(detail,pageno,pagesize);
    }

    //改变设计状态，并且指定仓库，对仓库的锁定库存增加
    @GetMapping("changeDetailInfoState.action")
    public Map changeDetailInfoState(Integer purchaseDetailInfoId,Integer warId){
        return purchaseDetailService.changeDetailInfoState(purchaseDetailInfoId,warId);
    }

    //重新指定仓库，对仓库的锁定库存进行修正增加
    @GetMapping("anewChangeDetailInfoState.action")
    public Map anewChangeDetailInfoState(Integer purchaseDetailInfoId,Integer warId){
        return purchaseDetailService.anewChangeDetailInfoState(purchaseDetailInfoId,warId);
    }
}
